﻿Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.DAO
Imports DevComponents.DotNetBar
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.General

Public Class frmTimNhaCungCap
    Private m_NhaCungCapCtrl As New NhaCungCapCtrl()
    Public Sub New()
        InitializeComponent()
        DataService.OpenConnection()
    End Sub

    Private Sub frmTimNhaCungCap_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        m_NhaCungCapCtrl.HienThi(DGVNhaCungCap, BindingNavigatorNhaCungCap)
    End Sub

#Region "Tìm kiếm nhà cung cấp"
    Private Sub btnSearch_KeyDown(sender As Object, e As KeyEventArgs)
        If e.KeyCode = Keys.Enter Then
            TimKiemNhaCungCap()
        End If
    End Sub

    Private Sub TimKiemNhaCungCap()
        Try
            If cbMaNCC.Checked = True Then
                m_NhaCungCapCtrl.TimKiemTheoMa(txtTimKiem.Text)
            ElseIf cbTenNCC.Checked = True Then
                m_NhaCungCapCtrl.TiemKiemTheoTen(txtTimKiem.Text)
            End If
        Catch
            MessageBoxEx.Show("Không thể tìm thấy Giá trị cần tìm!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.[Error])
        End Try
    End Sub

    Private Sub btnTimKiem_Click(sender As System.Object, e As System.EventArgs) Handles btnTimKiem.Click
        If txtTimKiem.Text = "" Then
            MessageBoxEx.Show("Giá trị tìm rỗng!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.[Error])
        Else
            TimKiemNhaCungCap()
        End If

    End Sub
#End Region

    Private Sub bindingNavigatorCloseItem_Click(sender As System.Object, e As System.EventArgs) Handles bindingNavigatorCloseItem.Click
        Me.Close()

    End Sub

    Private Sub btnHuy_Click(sender As System.Object, e As System.EventArgs) Handles btnHuy.Click
        Me.Close()

    End Sub
End Class